Sales Invoice POST

URI

https://{DATACENTER}.brightpearlconnect.com/public-api/{ACCOUNT}
/accounting-service/invoice/sales-invoice/

Refer to our documentation on URI syntax for more information on how to construct URIs.

Description

Transforms the sent Invoice resource into the corresponding journal lines. This endpoint uses specific logic to validate the invoice representation, but then delegates to the journal entry logic to validate and create the lines in the database. Note that creating the SI journal does not connect the order with that invoice transaction - the order will not be marked as invoiced. This would only happen if Sales Order Close POST is used.

Sales Invoice POST Validation

Mandatory elements are the header, and at least one line

The fields that are mandatory are:

  • contactId
  • taxDate
  • currencyId
  • exchangeRate (not mandatory for base currency)
  • Each line must have a net amount and a tax amount (values of the transaction in the currency stated), a tax code and a nominal code

Other validations are:

  • The order id must be in the system
  • The order must be of type sales order and belong to the customer
  • The contact must be of type customer
  • Nominal code can neither be Debtors Control Account ("1100", accounts receivable) nor Creditors Control Account ("2100", accounts payable)

The journal-entry POST is then validating additional accounting rules, if applicable.

Currency Conversions:

If SI is in foreign currency and previous journals are in base currency/multi currency feature toggle is off, we convert the SI values to base currency using the specified exchange rate and create the SI in base currency.

Prepayments and invoice clearing

If the posted SI has an order id the system searches for eventual prepayments for the same order id. If it finds any such prepayments it will update them with the invoice reference generated for the posted SI. If the prepayments value is enough to clear the invoice the invoice clearing (and eventual exchange variance calculation) is triggered. For further information please refer to the paragraph "invoice clearing" of the Sales Receipt POST.

Example

Creating a sales invoice journal for customer 200 at net value of 10 plus tax in the currency 2 at exchange rate 1.423567. Returns the journal id if successful. (Note that creating the SI journal does not yet connect the order with that invoice transaction - the order will not be marked as invoiced.)

Request URI

/invoice/sales-invoice/

Request body

{
	"header": {
		"contactId": 200,
		"taxDate": "2015-07-14",
		"dueDate": "2015-08-14",
		"description": "Sales invoice",
		"currencyId": 2,
		"exchangeRate": 1.423567,
		"orderId": 2
	},
	"lines": [
		{
			"net": 10.00,
			"tax": 2.00,
			"nominalCode": "4000",
			"taxClassId": 3,
			"projectId": 1,
			"leadSourceId": 1,
			"channelId": 1
		},
		{
			"net": 5.00,
			"tax": 0.00,
			"nominalCode": "4001",
			"taxClassId": 1,
			"projectId": 1,
			"leadSourceId": 1,
			"channelId": 1
		}
	]
}

Response

{
	"response": 20
}